package com.google.code.linescount.func;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;

public class MsgConsoleUtil {

	private static MessageConsole console;
	private static MessageConsoleStream stream;
	static {
		console=new MessageConsole("Lines Count",null);
		IConsoleManager manager = (IConsoleManager) ConsolePlugin.getDefault()
				.getConsoleManager();
		manager
				.addConsoles(new org.eclipse.ui.console.IConsole[] { (org.eclipse.ui.console.IConsole) console });
		manager.showConsoleView(console);
	}
	
	private MsgConsoleUtil(){
	}
	
	public static void print(String msg,int color) {
		stream=getConsole(color);
		stream.println(msg);
	}
	
	public static void printmsg(String msg) {
		print(msg,SWT.COLOR_BLUE);
	}
	
	public static void printerr(String error) {
		print(error,SWT.COLOR_RED);
	}
	
	private static MessageConsoleStream getConsole(int color) {
		final MessageConsoleStream consoleStream = console.newMessageStream();
		consoleStream.setColor(Display.getDefault().getSystemColor(color));
		return consoleStream;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {


	}

}
